﻿Public Class DALSYM
    Dim connect As CONDB = CONDB.NewConnection()
    'Dim connectlocal As conlocal = conlocal.NewConnection
    Dim PROVIDER_Check As New PROVIDERSCLASS

    Private Sub DRUGALLERGYSYMTOMP_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SelectDatagridMASSYMPTOM()

        DesignForm(Me)
        DesignGrid(MASSYMPTOMGrid)

        PROVIDER_Check.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub SelectDatagridMASSYMPTOM()
        Dim objSelectDataMASSYMPTOM As New massymptom
        Dim MASSYMPTOM As DataTable
        MASSYMPTOM = connect.GetTable(objSelectDataMASSYMPTOM.selectMassymptom_)
        MASSYMPTOMGrid.PrimaryGrid.DataSource = MASSYMPTOM
    End Sub

    Private Sub MASSYMPTOMGrid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASSYMPTOMGrid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        'f.TXT_CID.Text = grid.Cells.Item(2).Value
        SYMPTOMTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสลักษณะการแพ้ยา").Value()

        Try
            ICD10TMTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส ICD-10").Value()
        Catch ex As Exception
            ICD10TMTxt.Text = ""
        End Try

        SYMDESCTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("อาการแพ้ยา").Value()

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            massymptomStatusChk.Checked = True
        Else
            massymptomStatusChk.Checked = False
        End If

        Dim objChkboxUpdate As New CLICKGRIDCHECKBOX
        objChkboxUpdate.clickChkboxUpdate("massymptom", CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value(), "STATUS", "SYMPTOM", SYMPTOMTxt.Text)

        'editLabitem.Enabled = True
    End Sub


    Private Sub addMassymptom_Click(sender As Object, e As EventArgs) Handles addMassymptom.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If ICD10TMTxt.Text.ToString.Length > 0 And SYMDESCTxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New massymptom
                    objInsertData.ICD10TM_ = ICD10TMTxt.Text
                    objInsertData.SYMDESC_ = SYMDESCTxt.Text
                    objInsertData.STATUS_ = massymptomStatusChk.Checked
                    objInsertData.insertMassymptomData()

                    Dim objSelectDataMASSYMPTOM As New massymptom
                    Dim MASSYMPTOM As DataTable
                    MASSYMPTOM = connect.GetTable(objSelectDataMASSYMPTOM.selectMassymptom_)
                    MASSYMPTOMGrid.PrimaryGrid.DataSource = MASSYMPTOM

                    SYMPTOMTxt.Text = ""
                    ICD10TMTxt.Text = ""
                    SYMDESCTxt.Text = ""
                    massymptomStatusChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub


    Private Sub editMassymptom_Click(sender As Object, e As EventArgs) Handles editMassymptom.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If SYMPTOMTxt.Text.ToString.Length > 0 And ICD10TMTxt.Text.ToString.Length > 0 And SYMDESCTxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการแพ้ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New massymptom
                        objEditData.SYMPTOM_ = SYMPTOMTxt.Text
                        objEditData.ICD10TM_ = ICD10TMTxt.Text
                        objEditData.SYMDESC_ = SYMDESCTxt.Text
                        objEditData.STATUS_ = massymptomStatusChk.Checked
                        objEditData.editMassymptomData()

                        Dim objSelectDataMASSYMPTOM As New massymptom
                        Dim MASSYMPTOM As DataTable
                        MASSYMPTOM = connect.GetTable(objSelectDataMASSYMPTOM.selectMassymptom_)
                        MASSYMPTOMGrid.PrimaryGrid.DataSource = MASSYMPTOM

                        SYMPTOMTxt.Text = ""
                        ICD10TMTxt.Text = ""
                        SYMDESCTxt.Text = ""
                        massymptomStatusChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub


    Private Sub importExel_Click(sender As Object, e As EventArgs) Handles importExel.Click
        Dim nextform As New IMPORTEXCEL("massymptom")
        nextform.ShowDialog()
    End Sub

    Private Sub exportExcel_Click(sender As Object, e As EventArgs) Handles exportExcel.Click
        Dim nextform As New IMPORTEXCEL("massymptom")
        nextform.ShowDialog()
    End Sub
End Class